package org.omg.GIOP;

//
// Helper class for : MessageHeader_1_1
//
// @author OpenORB Compiler
//
public class MessageHeader_1_1Helper {

	//
	// Insert MessageHeader_1_1 into an any
	// @param a an any
	// @param t MessageHeader_1_1 value
	//
	public static void insert(org.omg.CORBA.Any a,
			org.omg.GIOP.MessageHeader_1_1 t) {
		a.insert_Streamable(new org.omg.GIOP.MessageHeader_1_1Holder(t));
	}

	//
	// Extract MessageHeader_1_1 from an any
	// @param a an any
	// @return the extracted MessageHeader_1_1 value
	//
	public static org.omg.GIOP.MessageHeader_1_1 extract(org.omg.CORBA.Any a) {

		return read(a.create_input_stream());
	}

	//
	// Internal TypeCode value
	//
	private static org.omg.CORBA.TypeCode _tc = null;
	private static boolean _working = false;

	//
	// Return the MessageHeader_1_1 TypeCode
	// @return a TypeCode
	//
	public static org.omg.CORBA.TypeCode type() {
		if (_tc == null) {
			synchronized (org.omg.CORBA.TypeCode.class) {
				if (_tc != null)
					return _tc;
				if (_working)
					return org.omg.CORBA.ORB.init().create_recursive_tc(id());
				_working = true;
				org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
				org.omg.CORBA.StructMember[] _members = new org.omg.CORBA.StructMember[5];

				_members[0] = new org.omg.CORBA.StructMember();
				_members[0].name = "magic";
				_members[0].type = org.omg.GIOP.CharSeq4Helper.type();
				_members[1] = new org.omg.CORBA.StructMember();
				_members[1].name = "GIOP_version";
				_members[1].type = org.omg.GIOP.VersionHelper.type();
				_members[2] = new org.omg.CORBA.StructMember();
				_members[2].name = "flags";
				_members[2].type = orb
						.get_primitive_tc(org.omg.CORBA.TCKind.tk_octet);
				_members[3] = new org.omg.CORBA.StructMember();
				_members[3].name = "message_type";
				_members[3].type = orb
						.get_primitive_tc(org.omg.CORBA.TCKind.tk_octet);
				_members[4] = new org.omg.CORBA.StructMember();
				_members[4].name = "message_size";
				_members[4].type = orb
						.get_primitive_tc(org.omg.CORBA.TCKind.tk_ulong);
				_tc = orb.create_struct_tc(id(), "MessageHeader_1_1", _members);
				_working = false;
			}
		}
		return _tc;
	}

	//
	// Return the MessageHeader_1_1 IDL ID
	// @return an ID
	//
	public static String id() {
		return _id;
	}

	private final static String _id = "IDL:omg.org/GIOP/MessageHeader_1_1:1.0";

	//
	// Read MessageHeader_1_1 from a marshalled stream
	// @param istream the input stream
	// @return the readed MessageHeader_1_1 value
	//
	public static org.omg.GIOP.MessageHeader_1_1 read(
			org.omg.CORBA.portable.InputStream istream) {
		org.omg.GIOP.MessageHeader_1_1 new_one = new org.omg.GIOP.MessageHeader_1_1();

		new_one.magic = org.omg.GIOP.CharSeq4Helper.read(istream);
		new_one.GIOP_version = org.omg.GIOP.VersionHelper.read(istream);
		new_one.flags = istream.read_octet();
		new_one.message_type = istream.read_octet();
		new_one.message_size = istream.read_ulong();

		return new_one;
	}

	//
	// Write MessageHeader_1_1 into a marshalled stream
	// @param ostream the output stream
	// @param value MessageHeader_1_1 value
	//
	public static void write(org.omg.CORBA.portable.OutputStream ostream,
			org.omg.GIOP.MessageHeader_1_1 value) {
		org.omg.GIOP.CharSeq4Helper.write(ostream, value.magic);
		org.omg.GIOP.VersionHelper.write(ostream, value.GIOP_version);
		ostream.write_octet(value.flags);
		ostream.write_octet(value.message_type);
		ostream.write_ulong(value.message_size);
	}

}
